<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 边界符 ^ $
      var rg = /abc/; //里面不用加引号  意思只要包含有abd 这个字符串返回的都是true
      console.log(rg.test("abc")); //true
      console.log(rg.test("abcad")); //true
      console.log(rg.test("aabcad")); //true
      var reg = /^abc/; // 意思是必须以 abc为开头的字符串
      console.log(reg.test("abc")); //true
      console.log(reg.test("abcad")); //true
      console.log(reg.test("aabcad")); //false
      var reg1 = /^abc$/; // 精确匹配 意思是必须以abc字符串才符合规范
      console.log(reg1.test("abc")); //true
      console.log(reg1.test("abcad")); //false
      console.log(reg1.test("aabcad")); //false
      console.log(reg1.test("abcabc")); // false
    </script>
  </body>
</html>
